var ajax = require('../../utils/ajax.js');
var util = require('../../utils/util.js');

Page({
  data: {
    selectList: ['我要开店', '系统BUG', '建议'],
    selectedIndex: 0,
    phone: '',
    content: '',
  },


  _selectQuesTy: function (e) {

    this.setData({
      selectedIndex: e.detail.value
    });
  },

  _phoneChange: function (e) {
    this.setData({
      phone: e.detail.value
    });
  },

  _contentChange: function (e) {
    this.setData({
      content: e.detail.value
    });
  },

  _submit: function () {
    if (this.data.selectedIndex == 0) {
      return util.alert('请选择你的问题类型');
    }
    if (!this.data.phone) {
      return util.alert('请输入你的手机号');
    }
    if (!this.data.content) {
      return util.alert('请输入你的问题描述');
    }
    ajax.P('/openapi/CHome/addFeedBack', {
      phone: this.data.phone,
      type: this.data.selectedIndex,
      content: this.data.content,
    }, function (data) {
      util.alert('谢谢您的支持！您的反馈我们会尽快处理！', function () {
        wx.switchTab({
          url: '../index/index'
        });
      });
    });
  }
});